package com.controller;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class test1 {
	public static void main(String[] args) throws ParseException {
	//	fun();
		SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
		String time = dateFormat.format(new Date());
		System.out.println(time);
		int mm=Integer.valueOf(time.substring(3));
		int mi=  mm/5;
		mi+=  (mm%5==0)?0:1 ;
	

		String ontime= time.substring(0, 2)+':'+ (mi<10?"0".concat(String.valueOf(mi)):String.valueOf(mi));
		System.out.println(ontime);
	}
	
	
	public static List fun() throws ParseException {
		
		
		Date d1 = new SimpleDateFormat("yyyy-MM-dd").parse("2017-5-30");// 定义起始日期

		Date d2 = new SimpleDateFormat("yyyy-MM-dd").parse("2017-12-8");// 定义结束日期

		Calendar dd = Calendar.getInstance();// 定义日期实例
		ArrayList list = new ArrayList();
		dd.setTime(d1);// 设置日期起始时间
       
        int xx=600;
		while (dd.getTime().before(d2)) {// 判断是否到结束日期
		   
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			String str = sdf.format(dd.getTime());
			Map mp=null;
			int xx1=0;
			while (xx1>1300||xx1<400) {
				mp=createmap(xx);
				xx1=(int)mp.get("closeprice");
			}
			xx=xx1;
			//System.out.println(str);// 输出日期结果		
			mp.put("everydate", str);
			list.add(mp);
			dd.add(Calendar.DATE, 1);// 进行当前日期月份加1

		}
		System.out.println(list);
		return list;
	}
	
		
	public static Map createmap(int x){
			
			
			Map map = new HashMap();
			map.put("openprice", x);
			int max = (int) (x + x * 0.1);

			Random random = new Random();
			int s[] = new int[3];
			int n = max - x;
			int f = random.nextInt(64);
			if (f % 10 >5) {
				s[0] = x - random.nextInt(n);
				s[1] = x - random.nextInt(n);
				s[2] = x - random.nextInt(n);
			} else {
				s[0] = random.nextInt(n) + x;
				s[1] = random.nextInt(n) + x;
				s[2] = random.nextInt(n) + x;
				
			}
			int maxprice = 0;
			int minprice = 99999;
			int sprice = 0;
			for (int i : s) {
				if (i > maxprice) {
					maxprice = i;
				}
				if (i < minprice) {
					minprice = i;
				}
			}
			for (int i : s) {
				if (i == maxprice || i == minprice) {
					continue;
				}
				sprice = i;
			}
			map.put("closeprice", sprice);
			map.put("maxprice", maxprice);
			map.put("minprice", minprice);
			
			
			return map;
		}

}
